<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>order管理</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/style.css">

    <!-- 上传图片框样式，不使用上传组件可以删除此样式 -->
    <style>
        .avatar-uploader .el-upload {
            border: 1px dashed #d9d9d9;
            border-radius: 6px;
            cursor: pointer;
            position: relative;
            overflow: hidden;
        }
        .avatar-uploader .el-upload:hover {
            border-color: #409EFF;
        }
        .avatar-uploader-icon {
            font-size: 28px;
            color: #8c939d;
            width: 150px;
            height: 70px;
            line-height: 150px;
            text-align: center;
        }
        .avatar {
            width: 150px;
            height: 70px;
            display: block;
        }

    </style>
</head>
<body class="hold-transition">
<div id="app">

    <div class="content-header">
        <h1>管理<small>order管理</small></h1>
        <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>管理</el-breadcrumb-item>
            <el-breadcrumb-item>order管理</el-breadcrumb-item>
        </el-breadcrumb>
    </div>

    <div class="app-container">
        <div class="box">
            <div class="filter-container">
                <!--查询表单-->
                <el-form :inline="true" >
<!--                    <el-form-item label="输入搜索">-->
<!--                        <el-input v-model="searchMap.id" placeholder="订单编号" class="filter-item" ></el-input>-->
<!--                    </el-form-item>-->
                    <el-form-item label="订单编号">
                        <el-input v-model="searchMap.id" placeholder="订单编号" class="filter-item" ></el-input>
                    </el-form-item>
                    <el-form-item label="物流单号">
                        <el-input v-model="searchMap.shippingCode" placeholder="物流单号" class="filter-item" ></el-input>
                    </el-form-item>
                    <el-form-item label="收货人">
                        <el-input v-model="searchMap.receiverContact" placeholder="收货人" class="filter-item" ></el-input>
                    </el-form-item>
                    <el-form-item label="收货人手机">
                        <el-input v-model="searchMap.receiverMobile" placeholder="收货人手机" class="filter-item" ></el-input>
                    </el-form-item>
                    <el-button class="dalfBut" type="primary" @click="fetchData()">查询</el-button>
                </el-form>
            </div>
            <div style="text-align: right">
                <el-button class="dalfBut" type="success" @click="gobatchOrders()">批量发货</el-button>
                <p></p>
            </div>

            <el-table :data="tableData" border style="width: 100%" @selection-change="handleSelectionChange">
                <el-table-column type="selection" width="55"></el-table-column>
<!--                <el-table-column prop="id" label="订单id" width="120"></el-table-column>-->
<!--                <el-table-column prop="createTime" label="提交时间" width="130"></el-table-column>-->
<!--                <el-table-column prop="username" label="用户账号" width="130"></el-table-column>-->
<!--                <el-table-column prop="payMoney" label="订单金额" width="130"></el-table-column>-->
<!--                <el-table-column prop="payType" label="支付类型，1、在线支付、0 货到付款" width="180"></el-table-column>-->
<!--                <el-table-column prop="postStatus" label="支付状态" width="130"></el-table-column>-->
                <el-table-column prop="id" label="订单编号" width="180"></el-table-column>
                <el-table-column prop="receiverContact" label="收货人" width="120"></el-table-column>
                <el-table-column prop="receiverMobile" label="收货人手机" width="150"></el-table-column>
                <el-table-column prop="createTime" label="提交时间" width="180"></el-table-column>
                <el-table-column prop="username" label="用户名称" width="110"></el-table-column>
                <el-table-column prop="totalMoney" label="金额合计" width="100"></el-table-column>
                <el-table-column label="支付方式" width="80">
                    <template slot-scope="scope">
                        <span v-if="scope.row.payType=='1'">在线支付</span>
                        <span v-if="scope.row.payType=='0'">货到付款</span>
                    </template>
                </el-table-column>
<!--                <el-table-column prop="sourceType" label="订单来源" width="80">-->
<!--                    <template slot-scope="scope">-->
<!--                        <span v-if="scope.row.sourceType=='1'">web</span>-->
<!--                        <span v-if="scope.row.sourceType=='2'">app</span>-->
<!--                        <span v-if="scope.row.sourceType=='3'">微信公众号</span>-->
<!--                        <span v-if="scope.row.sourceType=='4'">微信小程序</span>-->
<!--                        <span v-if="scope.row.sourceType=='5'">H5手机页面</span>-->
<!--                    </template>-->
<!--                </el-table-column>-->
                <el-table-column label="订单状态" width="80">
                    <template slot-scope="scope">
                        <span v-if="scope.row.orderStatus=='0'">待付款</span>
                        <span v-if="scope.row.orderStatus=='1'">待发货</span>
                        <span v-if="scope.row.orderStatus=='2'">已发货</span>
                        <span v-if="scope.row.orderStatus=='3'">已完成</span>
                        <span v-if="scope.row.orderStatus=='4'">已关闭</span>
                    </template>
                </el-table-column>

                <el-table-column label="操作">
                    <template slot-scope="scope">
                        <el-button @click="goOrderItem(scope.row.id)" size="mini" type="primary" size="small">查看订单</el-button>
                        <el-button @click="dele(scope.row.id)" size="mini" type="danger" size="small">删除</el-button>

                    </template>
                </el-table-column>
            </el-table>

            <div class="pagination-container">
                <el-pagination
                        class="pagiantion"
                        @size-change="fetchData"
                        @current-change="fetchData"
                        :current-page.sync="currentPage"
                        :page-sizes="[10, 20, 30, 40]"
                        :page-size="size"
                        layout="total, sizes, prev, pager, next, jumper"
                        :total="total">
                </el-pagination>
            </div>
        </div>
    </div>
</div>


</div>
</body>
<script src="/js/vue.js"></script>
<script src="/js/axios.js"></script>
<script src="/js/elementui.js"></script>
<script>
     new Vue({
        el: '#app',
        data(){
            return {
                tableData: [],
                currentPage: 1,
                total: 10,
                size: 10,
                searchMap: {},
                pojo: {},
                formVisible: false,
                imageUrl: '',
                ids:[]
            }
        },
        created(){
            this.fetchData();
        },
        methods:{
            gobatchOrders() {
                location.href = "batchOrders.html?ids=" + this.ids;
            },
            handleSelectionChange(val) {
                this.ids = [];
                for (const valElement of val) {
                    this.ids.push(valElement.id);
                }
                console.log(this.ids);
            },
            goOrderItem(id) {
                //规格列表
                location.href = "orderItem.html?orderId=" + id;
            },
            fetchData (){
                axios.post(`/order/findPage.do?page=${this.currentPage}&size=${this.size}`,this.searchMap).then(response => {
                    this.tableData = response.data.rows;
                    console.log(this.tableData);
                    this.total = response.data.total;
                });
            },
            save (){
                // this.pojo.image= this.imageUrl; //如页面有图片上传功能放开注释
                axios.post(`/order/${this.pojo.id==null?'add':'update'}.do`,this.pojo).then(response => {
                    this.fetchData (); //刷新列表
                    this.formVisible = false ;//关闭窗口
                });
            },
            edit (id){
                this.formVisible = true // 打开窗口
                // 调用查询
                axios.get(`/order/findById.do?id=${id}`).then(response => {
                    this.pojo = response.data;
                    // this.imageUrl=this.pojo.image //显示图片  如页面有图片上传功能放开注释
                })
            },
            dele (id){
                this.$confirm('确定要删除此记录吗?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then( () => {
                    axios.get(`/order/delete.do?id=${id}`).then(response => {
                        this.fetchData (); //刷新列表
                    })
                })
            }
        }
    })
</script>
</html>
